/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package test;

import item.Item;
import item.ItemInfo;
import java.sql.Date;
import myJPA.Model;
import transactions.LateCharge;
import transactions.RentalList;
import user.Customer;
import user.Employee;

/**
 *
 * @author ZIZI
 */
public class ManageRentalList {
     
    public static void main(String[] args)
    {
    //TEST 1
        if(addRentalTest())
            System.out.println("Test 1 successful");
        else
            System.out.println("Test 1 failed");
        
        
            /*     //TEST 2
        if(recordReturnTest())
            System.out.println("Test 2 successful");
        else
            System.out.println("Test 2 failed");*/
            
    } 
    public static boolean addRentalTest()
    {
        Customer customer = new Customer("Saad", "Khalil", "rabat, Maroc", "0661601996", new Date(2012, 11, 25));
        customer.save();
        customer.refresh();
        Item item = new Item("Skyfall", 10, "Movie");
        item.save();
        item.refresh();
        Employee employee = new Employee("Hamid", "El kasri", "Casablanca, Maroc", "0665778813", "siHamid", "Clerk", "salam");
        employee.save();
        employee.refresh();
        
        ItemInfo videoInfo = new ItemInfo("Movie", 10, 15, 20);
        videoInfo.save();
        ItemInfo videoGameInfo = new ItemInfo("VideoGame", 12, 15, 20);
        videoGameInfo.save();
        
        RentalList.addRental(customer, item, employee);
        
        RentalList.RecordReturn(customer, item, employee);
        
        Item saved = (Item) Model.getEntityManager().find(Item.class, item.getId());
        
        if(saved == null)
            return true;
        return false;
            
    }
}
